﻿using HCQ2_Common;
using HCQ2_Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HCQ2UI_Helper.Log
{
    public class OperatorLog
    {
        #region 4.0 系统操作日志
        /// <summary>
        ///  添加系统操作日志
        /// </summary>
        /// <param name="context">操作内容</param>
        /// <param name="user_id">操作用户id</param>
        /// <param name="user_name">操作用户名称</param>
        /// <param name="module_name">模块名称</param>
        /// <param name="module_code">模块代码</param>
        /// <param name="page_name">页面名称</param>
        /// <param name="button_name">按钮</param>
        public static void AddOperatorLog(string context, int user_id, string user_name, string module_name, string module_code, string page_name=null, string button_name=null)
        {
            if (string.IsNullOrEmpty(module_name) || string.IsNullOrEmpty(module_code) || string.IsNullOrEmpty(context))
                return;
            try
            {
                T_VROperatorLog log = new T_VROperatorLog
                {
                    log_code = Helper.GetGuid,
                    ip = RequestHelper.GetIP,
                    create_date = DateTime.Now,
                    user_id = user_id,
                    user_name = user_name,
                    module_name = module_name,
                    module_code = module_code,
                    page_name = page_name,
                    button_name = button_name,
                    context = context
                };
                OperateContext.Current.bllSession.T_VROperatorLog.Add(log);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion
    }
}
